{% extends "templates/atnet_base.html" %}

{% block csslink %}
		{{ super() }}
<script src="/media/js/jquery.js"></script>

{% include 'templates/includes_datatable.html' %}
{% include 'templates/includes_jquery_ui.html' %}
<script src="/media/js/form_popup.js"></script>

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
	var wasAction = false;
	
	$('#diverse-operations').dataTable({
		"bPaginate": false,
		"bLengthChange": false,
		"bFilter": true,
		"bSort": true,
		"bInfo": false,
		"bAutoWidth": false,
		"oLanguage": {
            "sUrl": "/media/js/dataTables.{{ app_user.lang }}.txt"
        },
		"bProcessing": true,
		"sAjaxSource": "{{ uri_for('diverse_operations', imm_id=immeuble.key().id(), command='list_json') }}",
		"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
			$('td:eq(11)', nRow).html('<a href="javascript:void(0);" id="' + aData[11] + '">{{ _("Edit") }}</a>');
		},
	});
	
	$('#add-do').live('click', function(){
		$(this).LaunchPopup(
			{
				TableId: '#diverse-operations',
				DivId: '#dialog-form',
				FormId: '#generated-form',
				UrlForm: "{{ uri_for('diverse_operations', imm_id=immeuble.key().id(), command='add') }}",
				Mode: 'add',
				Title: '{{ _("Add diverse operation") }}',
				UrlReturn: "{{ uri_for('diverse_operations', imm_id=immeuble.key().id(), command='list') }}"
			}
		)
	});
	
	$('#diverse-operations tbody tr a').live('click', function(e) {
		$(this).LaunchPopup(
			{
				TableId: '#diverse-operations',
				DivId: '#dialog-form',
				FormId: '#generated-form',
				UrlForm: "{{ uri_for('diverse_operations', imm_id=immeuble.key().id(), command='edit') }}" + e.target.id + "/",
				Mode: 'edit',
				Title: '{{ _("Edit diverse operation") }}',
				UrlReturn: "{{ uri_for('diverse_operations', imm_id=immeuble.key().id(), command='list') }}"
			}
		)
	});
});
</script>
{% endblock %}

{% block title %} 
	{{ title }}
{% endblock %}

{% block header %}
{{ header }}
{% endblock %}

{% block login%}
{% if show_login %}
{{ super() }}
{% endif %}
{% endblock%}

{% block navigation %}
{% if not show_login %}
{{ super() }}
{% endif %}
{% endblock %}

{% block section_menu %}
{% include 'templates/includes_vie_de_la_copropriete.html' %}
{% endblock %}

{% block main_content %}
<p>
	<p><a href="javascript:void(0);" id="add-do">{{ _('Add diverse operation') }}</a></p>
	<div id="demo">
	<table cellpadding="0" cellspacing="0" border="0" class="display" id="diverse-operations" width="100%">
		<thead>
			<tr>
				<th>{{ _(fields.od_date) }}</th>
				<th>{{ _(fields.subaccount_debit) }}</th>
				<th>{{ _(fields.subaccount_credit) }}</th>
				<th>{{ _(fields.journal) }}</th>
				<th>{{ _(fields.number) }}</th>
				<th>{{ _(fields.lable) }}</th>
				<th>{{ _(fields.amount) }}</th>
				<th>{{ _(fields.tva) }}</th>
				<th>{{ _(fields.rental_charges) }}</th>
				<th>{{ _(fields.tax_deduction) }}</th>
				<th>{{ _(fields.property_income_deduction) }}</th>
				<th width="20"></th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td colspan="11" class="dataTables_empty">{{ _('Loading data from server') }}</td>
			</tr>
		</tbody>
		<tfoot>
			<tr>
				<th>{{ _(fields.od_date) }}</th>
				<th>{{ _(fields.subaccount_debit) }}</th>
				<th>{{ _(fields.subaccount_credit) }}</th>
				<th>{{ _(fields.journal) }}</th>
				<th>{{ _(fields.number) }}</th>
				<th>{{ _(fields.lable) }}</th>
				<th>{{ _(fields.amount) }}</th>
				<th>{{ _(fields.tva) }}</th>
				<th>{{ _(fields.rental_charges) }}</th>
				<th>{{ _(fields.tax_deduction) }}</th>
				<th>{{ _(fields.property_income_deduction) }}</th>
				<th></th>
			</tr>
		</tfoot>
	</table>
	</div>
	{% include 'templates/includes_popup_form.html' %}
</p>
<script>
$(function() {
	var user_lang = "{{ app_user.lang }}";
	if (user_lang == "en") { user_lang = "en-GB" };
	$.datepicker.setDefaults( $.datepicker.regional[ user_lang ] );
	
	$("#od_date").live("focus", function() {
	    $(this).datepicker({
	        inline: true 
	    });
	});
	
	var availableTagsA;
	availableTagsA = getMessages("{{ uri_for('parametrage_account', imm_id=immeuble.key().id(), command='list_names_json') }}");
	$("#subaccount_debit").live("focus", function() {
		$(this).autocomplete({
			delay: 0,
			minLength: 0,
			source: availableTagsA
		});
		$(this).data("autocomplete").search($(this).val());
	});
	$("#subaccount_credit").live("focus", function() {
		$(this).autocomplete({
			delay: 0,
			minLength: 0,
			source: availableTagsA
		});
		$(this).data("autocomplete").search($(this).val());
	});
});
</script>
{% endblock %}
